# _*_ coding : utf-8 _*_
# @Time : 2022/8/7 18:14
# @Author : Moonquake
# @File : 9.urllib.请求对象的定制
# @Project : python

# url的组成
# 协议    主机    端口号      路径    参数    锚点
import urllib.request
url='http://www.baidu.com'
headers={
    'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.134 Safari/537.36 Edg/103.0.1264.77'
}
# 请求对象的定制
request = urllib.request.Request(url=url,headers=headers)
response = urllib.request.urlopen(request)
content = response.read().decode('utf-8')
print(content)